package com.kevin.servlet3;

import java.io.IOException;
import java.util.Date;

import javax.servlet.AsyncContext;
import javax.servlet.ServletResponse;

public class MyThread extends Thread {

	private AsyncContext asyncContext;

	public MyThread(AsyncContext asyncContext) {

		this.asyncContext = asyncContext;
	}

	@Override
	public void run() {

		try {
			Thread.sleep(5000);

			ServletResponse resp = this.asyncContext.getResponse();
			resp.getWriter().println("severlet end:" + new Date());

			System.out.println("asyncContext onComplete");
			this.asyncContext.complete();
			
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
